/**
 * 
 */
package com.newtribe.util;

import java.io.*; 
import java.util.*; 
import javax.tools.*; 

/**
 * @author newtribe
 *
 */
public class CompileUtil {

 public static void main(String args[]) throws IOException { 
			  
		 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); 
		 DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); 
		StandardJavaFileManager fileManager =  compiler.getStandardFileManager(diagnostics, null, null); 
		// Iterable compilationUnits =  fileManager.getJavaFileObjectsFromStrings(Arrays.asList("WsdlUtils.java"));
		 Iterable compilationUnits =fileManager.getJavaFileObjects(new File("E:/mywork/security/src/com/newtribe/wsdl/WsdlUtils.java"));
		 
		 
		JavaCompiler.CompilationTask task = compiler.getTask( null, fileManager, diagnostics, null, null, compilationUnits); 
		
		Boolean success = task.call(); 
		for (Diagnostic diagnostic : diagnostics.getDiagnostics()) { 
			System.out.println(diagnostic.getMessage(null));
			System.out.println(diagnostic.getCode());
			System.out.println(diagnostic.getSource());
			
			 } 
			 fileManager.close(); 
		 System.out.println("Success: " + success); 
} 

}
